-
Notifications
You must be signed in to change notification settings - Fork 2.1k
drivers/hall_effect: support for generic hall effect sensors #21801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
crasbe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open Review Comments:
|
I only briefly (like 5 minutes) looked at this, but it reminds me of the |
Thanks I overlooked |
| ztimer_periodic_init(ZTIMER_USEC, &dev->rpm_timer, _rpm_calc_timer_cb, (void *) dev, | ||
| CONFIG_INC_ENCODER_HARDWARE_PERIOD_MS * US_PER_MS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it actually necessary to use the microsecond timer here? It prevents deeper sleep modes on most microcontrollers 🤔
| #else | ||
| # define INC_ENCODER_PARAMS {} | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably unncessary, as this wouldn't work without a software or hardware interface anyways.
| * the detected rotation direction will be reversed. | ||
| * | ||
| * The driver provides functions to read the current RPM | ||
| * and the total number of revolutions (in hundredths) since the last measurement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like "in one hundreths of a revolution" as in "1/100th revolution" 🤔
| * This driver implements the SAUL sensor interface. | ||
| * It provides two SAUL devices: | ||
| * - One for reading the current RPM | ||
| * - One for reading the total number of revolutions in hundredths since the last read. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
| SAUL_SENSE_ID_PH, /**< sensor: pH */ | ||
| SAUL_SENSE_ID_POWER, /**< sensor: power */ | ||
| SAUL_SENSE_ID_SIZE, /**< sensor: size */ | ||
| SAUL_SENSE_ID_SPEED, /**< sensor: speed */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| SAUL_SENSE_ID_SPEED, /**< sensor: speed */ | |
| SAUL_SENSE_ID_SPEED, /**< sensor: speed */ |
| /** sensor: size */ | ||
| SAUL_SENSE_SIZE = SAUL_CAT_SENSE | SAUL_SENSE_ID_SIZE, | ||
| /** sensor: speed */ | ||
| SAUL_SENSE_SPEED = SAUL_CAT_SENSE | SAUL_SENSE_ID_SPEED, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| SAUL_SENSE_SPEED = SAUL_CAT_SENSE | SAUL_SENSE_ID_SPEED, | |
| SAUL_SENSE_SPEED = SAUL_CAT_SENSE | SAUL_SENSE_ID_SPEED, |
Contribution description
This introduces a new driver, a test for the driver, and a new SAUL category ID.
Hall effect sensor / magnetic rotary encoder are often attached directly to the shaft of a motor but can also be bough and used independently.
This driver is not specific to one model sensor. The driver can be used to measure RPM and revolutions since the last readout.
The test just periodically prints the RPM and revolutions since the last read.
The only other drivers measuring angular velocity were gyro drivers which have a SAUL category ID of there own. Therefore I introduced
SAUL_SENSE_SPEED.Testing procedure
I connected a sensor and ran the provided test and tested it form the shell via the SAUL adaptation.